package cc.bukkitPlugin.banitem.check;

public class SimpleWorld{

    public final static SimpleWorld defaultWorld=new SimpleWorld(null);

    private final String mRawWorld;
    private final String mLowerWorld;

    /**
     * 创建一个简单世界Warp
     * @param pRawWorld 世界名字
     */
    private SimpleWorld(String pRawWorld){
        this.mRawWorld=pRawWorld;
        this.mLowerWorld=pRawWorld==null?null:pRawWorld.toLowerCase();
    }

    public String getRawWorld(){
        return this.mRawWorld;
    }

    @Override
    public int hashCode(){
        return this.mLowerWorld==null?0:this.mLowerWorld.hashCode();
    }

    @Override
    public boolean equals(Object obj){
        if(obj==null){
            return false;
        }
        if(obj instanceof SimpleWorld){
            return ((SimpleWorld)obj).hashCode()==this.hashCode();
        }
        return false;
    }

    @Override
    protected Object clone(){
        return new SimpleWorld(this.mRawWorld);
    }

    @Override
    public String toString(){
        return this.mRawWorld==null?"全局":this.mRawWorld.toString();
    }

    public static SimpleWorld create(String pRawWorld){
        if(pRawWorld==null)
            return SimpleWorld.defaultWorld;
        else return new SimpleWorld(pRawWorld);
    }

}
